<?php


namespace apps\marriage\core\model;


use vm\com\BaseModel;

class MemberProfile extends BaseModel
{
    const VIP_LEVEL_BRONZE = 5;         // 青铜会员
    const VIP_LEVEL_YELLOW_GOLD = 10;   // 黄金会员
    const VIP_LEVEL_WHITE_GOLD = 20;    // 白金会员
    const VIP_LEVEL_PLATINUM = 30;    // 铂金会员
    const VIP_LEVEL_BLUE_DIAMOND = 36;       // 蓝钻会员
    const VIP_LEVEL_RED_DIAMOND = 50;       // 红钻会员
    const VIP_LEVEL_BLUE_CROWN = 60;       // 蓝冠会员
    const VIP_LEVEL_GOLD_CROWN = 70;       // 金冠会员

    const GENDER_MALE = 1;
    const GENDER_FEMALE = 2;

    // 形象照审核状态
    const PHOTO_AUDIT_STATUS_AUDITING = 10;     // 审核中
    const PHOTO_AUDIT_STATUS_APPROVED = 20;     // 审核通过
    const PHOTO_AUDIT_STATUS_REJECT = 30;     // 未通过

    public static function genders()
    {
        return [
            0 => '保密',
            self::GENDER_MALE => '男',
            self::GENDER_FEMALE => '女'
        ];
    }

    public static function marriageStatus()
    {
        return [
            10 => '未婚',
            20 => '离异',
            30 => '丧偶'
        ];
    }

    public static function houseStatus()
    {
        return [
            0 => '未知',
            10 => '暂未购房',
            20 => '已购住房'
        ];
    }

    public static function carStatus()
    {
        return [
            0 => '未知',
            10 => '未购车',
            20 => '已购车'
        ];
    }

    public static function distanceRelationshipTypes()
    {
        return [
            0 => '未知',
            10 => '不接受',
            20 => '接受'
        ];
    }

    public static function childTypes()
    {
        return [
            0 => '未知',
            10 => '愿意',
            20 => '不愿意',
            30 => '视情况而定'
        ];
    }

    public static function liveParentsTypes()
    {
        return [
            0 => '未知',
            10 => '愿意',
            20 => '不愿意',
            30 => '视情况而定'
        ];
    }

    public static function  incomes()
    {
        return [
            10 => '5万以下',
            20 => '5-10万',
            30 => '10-20万',
            40 => '20-30万',
            50 => '30-50万',
            60 => '50-100万',
            70 => '100万以上'
        ];
    }

    public static function jobs()
    {
        return [
            10 => '运动员',
            20 => '教师',
            30 => '教授',
            40 => '学生',
            50 => '董事长',
            60 => '总经理',
            70 => '副总/总监',
            80 => '部门经理',
            90 => '中层管理',
            100 => '企业家',
            110 => '个体老板',
            120 => '高级干部',
            130 => '公务员',
            140 => '律师',
            150 => '医生',
            160 => '护士',
            170 => '专家学者',
            180 => '工程师',
            190 => '设计师',
            200 => '艺术家',
            210 => '演员',
            220 => '模特',
            230 => '离/退休',
            240 => '技术员',
            250 => '服务员',
            260 => '普通员工',
            270 => '自由职业',
            290 => '程序员',
            280 => '无业',
            300 => '设计师',
            310 => '销售',
            320 => '公司职员',
            330 => '空姐',
            340 => '主播',
            350 => '主持人',
            600 => '其它'
        ];
    }

    public static function nations()
    {
        return [
            10 => '汉族',
            20 => '藏族',
            30 => '朝鲜族',
            40 => '蒙古族',
            50 => '回族',
            60 => '满族',
            70 => '维吾尔族',
            80 => '壮族',
            90 => '彝族',
            100 => '苗族',
            200 => '其他民族'
        ];
    }

    public static function bloodTypes()
    {
        return [
            10 => 'A型',
            20 => 'B型',
            30 => 'O型',
            40 => 'AB型',
            100 => '其他'
        ];
    }

    public static function kids()
    {
        return [
            10 => '没有',
            20 => '有,和我住一起',
            30 => '有,有时和我住一起',
            40 => '有，不和我住一起'
        ];
    }

    public static function faiths()
    {
        return [
            10 => '无宗教信仰',
            20 => '大乘佛教显宗',
            30 => '大乘佛教密宗',
            40 => '小乘佛教',
            50 => '道教',
            60 => '儒教',
            70 => '基督教天主教派',
            80 => '基督教东正教派',
            90 => '基督教新教派',
            100 => '犹太教',
            110 => '伊斯兰教什叶派',
            120 => '伊斯兰教逊尼派',
            130 => '印度教',
            140 => '神道教',
            150 => '萨满教',
            200 => '其他宗教信仰'
        ];
    }

    public static function drinks()
    {
        return [
            10 => '不喝酒',
            20 => '社交需要喝',
            30 => '兴致时小酌',
            40 => '酒不离口'
        ];
    }

    public static function smokes()
    {
        return [
            10 => '不吸，很反感',
            20 => '不吸烟，但不反感',
            30 => '社交时偶尔吸烟',
            40 => '烟不离手'
        ];
    }

    public static function jobTypes()
    {
        return [
            10 => '政府机关',
            20 => '事业单位',
            30 => '外企企业',
            40 => '世界500强',
            50 => '上市公司',
            60 => '国有企业',
            70 => '私营企业',
            80 => '自有公司'
        ];
    }

    public static function educationTypes()
    {
        return [
            10 => '中专以下',
            20 => '中专',
            30 => '大专',
            40 => '本科',
            50 => '硕士',
            60 => '博士',
            70 => '博士后'
        ];
    }


    /**
     * 按条件分页查询
     * @param array $params
     * @param $pageSize
     * @param array $paginateConfig
     * @return array|null
     * @throws \think\exception\DbException
     */
    public function pageListByParams(array $params, $pageSize, array $paginateConfig = [], array $sortOrder = [])
    {
        if(empty($params)) {
            $pk = $this->getPk();
            $query = $this;
            $query = $query->where('gender', '>', 0);
            $sortOrder = [$pk => 'desc'];
            $paginateConfig['list_rows'] = $pageSize;
            $data = $query->order($sortOrder)->paginate($paginateConfig, false)->toArray();
            return $data;
        }
        $pk = $this->getPk();
        $query = $this;
        foreach ($params as $key => $val) {
            if(is_array($val)) {
                $query = $query->where($key, $val[0], $val[1]);
            } else {
                if($key == 'min_age') {
                    $query = $query->where('birthday', '>=', $val);
                } else if($key == 'max_age') {
                    $query = $query->where('birthday', '<=', $val);
                } else {
                    $query = $query->where($key, $val);
                }
            }
        }
        if(!isset($params['gender'])) {
            $query = $query->where('gender', '>', 0);
        }
        if(empty($sortOrder)) {
            $sortOrder = [$pk => 'desc'];
        }
        $paginateConfig['list_rows'] = $pageSize;
        $data = $query->order($sortOrder)->paginate($paginateConfig, false)->toArray();
        return $data;
    }
}